package com.tensai.study.java.newconcept.typereactiveprogram.reactor.flux;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * 递归操作
 *
 * @author Tensai
 */
@Slf4j
public class ExpandTest {

	@Test
	public void expandTest() {
		Flux.just(1, 2)
				.expand(item -> {
					log.warn("item ==> {}", item);
					if (item > 6) {
						log.error("over");
						return Mono.empty();
					} else {
						return Flux.just(item * 3);
					}
				})
				.subscribe(it -> log.info(it.toString()));
	}
}
